//导入vue-router包
import VueRouter from 'vue-router'

//导入对应的路由组件
// import Test from './components/test/test.vue'	
// import HsIndex from './components/hsPage/index.vue'	
// import HsChoice from './components/hsPage/choice.vue'
// import HsSearch from './components/hsPage/search.vue'	
// import HsFault from './components/hsPage/fault.vue'	
// import HsInfo from './components/hsPage/info.vue'	
// import HsAgree from './components/hsPage/agreement.vue'	
// import HsSuccess from './components/hsPage/success.vue'	
// import HsqLogin from './components/hsPage/login.vue'	
// import HsqCenter from './components/hsPage/center.vue'	
// import HsqList from './components/hsPage/queryList.vue'	
// import HsqDetail from './components/hsPage/queryDetail.vue'	
// import HsqMail from './components/hsPage/queryMail.vue'	
// import HsqAccount from './components/hsPage/account.vue'	//账户管理	
// import HsqAccountModify from './components/hsPage/accountModify.vue'	//账户信息修改	
// import HsqPwdModify from './components/hsPage/accountPwdModify.vue'	//登录密码修改	
// import HsqHelp from './components/hsPage/help.vue'	//帮助中心	

const Test =r => require([ './components/test/test.vue'], r)	
const HsIndex =r => require([ './components/hsPage/index.vue'], r)	
const HsChoice =r => require([ './components/hsPage/choice.vue'], r)
const HsSearch =r => require([ './components/hsPage/search.vue'	], r)
const HsFault =r => require([ './components/hsPage/fault.vue'], r)	
const HsInfo =r => require([ './components/hsPage/info.vue'	], r)
const HsAgree =r => require([ './components/hsPage/agreement.vue'], r)	
const HsSuccess =r => require([ './components/hsPage/success.vue'], r)	
const HsqLogin =r => require([ './components/hsPage/login.vue'	], r)
const HsqCenter =r => require([ './components/hsPage/center.vue'], r)	
const HsqList =r => require([ './components/hsPage/queryList.vue'	], r)
const HsqDetail =r => require([ './components/hsPage/queryDetail.vue'], r)	
const HsqMail =r => require([ './components/hsPage/queryMail.vue'], r)	
const HsqAccount =r => require([ './components/hsPage/account.vue'], r)	//账户管理	
const HsqAccountModify =r => require([ './components/hsPage/accountModify.vue'], r)	//账户信息修改	
const HsqPwdModify =r => require([ './components/hsPage/accountPwdModify.vue'], r)	//登录密码修改	
const HsqHelp =r => require([ './components/hsPage/help.vue'], r)	//帮助中心	


//创建路由对象
var router = new VueRouter({
	routes: [   //配置路由规则
		//回收首页
		{ path: '/', redirect: '/hsindex' },
		//回收首页
		{ path: '/hsindex', component: HsIndex, meta: {title: '手服网-手机回收'}},
		//选择品牌型号
		{ 
			path: '/hschoice', 
			component: HsChoice, 
			meta: {title: '手机回收-选择品牌、型号'},
			//搜索品牌型号
			children: [
				{
					path: 'search',
					component: HsSearch
				}
			] 
		},
		//选择故障信息
		{ 
			path: '/hsfault', 
			component: HsFault,
			//填写用户信息，提交订单
			children: [	
				{
					path: 'hsinfo',
					component: HsInfo,
					children: [
						//用户协议
						{
							path: 'hsagree',
							component: HsAgree
						}
					] 
				}
			] 
		},
		//下单成功页面
		{ path: '/hssuccess', component: HsSuccess, meta: {title: '手机回收-下单成功'}},
		//用户登录界面
		{ path: '/hsqlogin',  component: HsqLogin,  meta: {title: '手机回收-用户登录'}},
		//个人中心
		{ 
			path: '/hsqlogin/hsqcenter',  
			component: HsqCenter, 
			meta: {title: '手机回收-个人中心'},
			children: [
				//订单列表
				{
					path: 'hsqlist', 
					component: HsqList, 
					meta: {title: '个人中心-订单列表'} 
				},
				//帮助中心
				{
					path: 'hsqhelp', 
					name: 'HsqHelp',
					component: HsqHelp, 
					meta: {title: '个人中心-帮助中心'} 
				},
				//订单详情页面
				{
					path: 'hsqdetail', 
					component: HsqDetail, 
					meta: {title: '订单列表-订单详情'},
					children: [
						{
							//快递信息
							path: 'mail',
							component: HsqMail,
							meta: {title: '订单详情-快递信息'},
						}
					] 
				},
				//账户管理
				{
					path: 'account', 
					name: 'HsqAccount',
					component: HsqAccount, 
					meta: {title: '个人中心-账户管理'} ,
					children: [
						{
							//账户修改
							path: 'modify',
							name: 'HsqAccountModify',
							component: HsqAccountModify,
							meta: {title: '账户管理-信息修改'},
						},
						{
							//密码修改
							path: 'pwdmodify',
							name: 'HsqPwdModify',
							component: HsqPwdModify,
							meta: {title: '账户管理-密码修改'},
						}
					]
				},
			] 
		}
		

	],
	// linkActiveClass: 'a-active',  //覆盖默认路由高亮的类，默认的类叫做router-link-active
})

router.beforeEach((to, from, next) => {
	/* 路由发生变化修改页面title */
	if (to.meta.title) {
		document.title = to.meta.title
	}
	next()
})

//导出路由对象
export default router